﻿package com.ufenlei.LTS{
	import flash.events.Event;

	public class TestingGroup extends ScrolledBlock{
		private var _id:uint;
		private var _title:String; 
		private var _type:String;
		private var _soundURL:String;
		private var _testingItemList:Array= new Array();
		public static const TEXT:String = "T";
		public static const IMAGE:String = "P";
		private var itemviewList:Array = new Array();
		private var num:int = 0;
		public function TestingGroup(Uid:uint,Stitle:String,SsoundURL:String, w:uint = 400,h:uint=300, Utype:String = "T"){
			super(w,h);
			_id = Uid;
			_title = Stitle;
			_type = Utype;
			_soundURL = SsoundURL;
		}
		public function add(ti:TestingItem):void{
			var tv:TestingItemView = new TestingItemView(ti);
			tv.addEventListener(Input.CHANGE, onTvChange);
			this.addContent(tv,10);
			_testingItemList.push(ti);
			itemviewList.push(tv);
			tv.init();
		}
		public function showKey():void{
			for(var i=0; i<this._testingItemList.length; i++){
				this.itemviewList[i].showKey();
			}
		}
		public function get list():Array{
			return this._testingItemList;
		}
		public function get title():String{
			return _title;
		}
		public function get id():uint{
			return _id;
		}
		public function get soundURL():String{
			return _soundURL;
		}
		private function onTvChange(evt:Event):void{
			this.dispatchEvent(evt.clone());
			var idx:int = Math.min(this._containtList.indexOf(evt.target as TestingItemView)+1,this._containtList.length - 1);
			var nextTV:TestingItemView = this._containtList[idx];
			moveTo(nextTV);
		}
	}
}